// compile: g++ -o relaxed relaxed.cc -std=c++11
// run: ./relaxed
#include <atomic>
#include <iostream>
#include <thread>
#include <vector>
using namespace std;

void Test1() {
  atomic<int> count = {0};
  std::vector<std::thread> vec;
  for (int i = 0; i < 100; i++) {
    vec.emplace_back([&]() { count.fetch_add(1, std::memory_order_relaxed); });
  }
  for (auto& t : vec) {
    t.join();
  }
  cout << "count= " << count << endl;
}
int main() {
  Test1();
  return 0;
}
